﻿namespace Digitalmes.Common.Exceptions;

/// <summary>
/// 应用程序友好异常
/// </summary>
public sealed class FriendlyException : Exception
{
    /// <summary>
    /// 错误码
    /// </summary>
    public int ErrorCode { get; init; }

    /// <summary>
    /// 错误消息
    /// </summary>
    public string? ErrorMessage { get; init; }

    public FriendlyException(string message) : base()
    {
        ErrorCode = -1;
        ErrorMessage = message;
    }

    public FriendlyException(int errorCode, string? message) : base(message)
    {
        ErrorCode = errorCode;
        ErrorMessage = message;
    }

    public FriendlyException(int errorCode, string? message, Exception? innerException) : base(message, innerException)
    {
        ErrorCode = errorCode;
        ErrorMessage = message;
    }
}
